{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_my_wtf_macros.html" as my_wtf_macros %}
{% import "_macros.html" as macros %}

{% block title %}万屏时代OPC--微信用户列表{% endblock %}

{% block panel_heading %}
  万屏时代OPC--微信用户列表
{% endblock %}

{% block panel_body %}

    <form id="search-demand-form" action="{{ url_for('opc_wechat_bp.wechat_user_list') }}" method="post" class="form" role="form">
        {{ my_wtf_macros.form_field(form.nickname, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.subscribe, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.invite_user_id, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.subscribe_time_begin, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.subscribe_time_end, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.is_invite_user, div_col=4, label_col=4, field_col=7) }}
        <div class="pull-right btn-group">
            <button type="submit" class="btn btn-info"
                    id="query-demand-btn">
                查询
            </button>
        </div>
    </form>

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'opc_wechat_bp.wechat_user_list', **url_kwargs) }}
    </div>
    {% endif %}

    <table id="wechat_template_table" class="table table-bordered table-hover table-condensed table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>昵称</th>
                <th>电话号码</th>
                <th>性别</th>
                <th>省份</th>
                <th>城市</th>
                <th>关注时间</th>
                <th>关注状态</th>
                <th>邀请人</th>
                <th>邀请时间</th>
                <th>邀请状态</th>
                <th>邀请购买套餐状态</th>
            </tr>
        </thead>
        <tbody>
            {% for user in wechat_users %}
            <tr>
                <td>{{ user.id }}</td>
                <td>
                    {% if user.user %}
                        <a href="{{ url_for('op_bp.user_info', user_id=user.user.id) }}">{{ user.nickname }}</a>
                    {% else %}
                        {{ user.nickname }}
                    {% endif %}
                </td>
                <td>{{ user.user.mobile | encrypt  }}</td>
                <td>{{ user.sex_display }}</td>
                <td>{{ user.province }}</td>
                <td>{{ user.city }}</td>
                <td>{{ user.subscribe_time_display }}</td>
                <td>{{ user.subscribe_display }}</td>
                <td>
                    {% if user.invite_user %}
                        <a href="{{ url_for('op_bp.user_info', user_id=user.invite_user.id) }}">{{ user.invite_user.nickname }}</a>
                    {% else %}
                        无
                    {% endif %}
                </td>
                <td>{{ user.invite_time_display or '' }}</td>
                <td>{{ user.invite_state_display }}</td>
                <td>{{ user.invite_buy_pack_display }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'opc_wechat_bp.wechat_user_list', **url_kwargs) }}
    </div>
    {% endif %}
{% endblock %}

